Today's session is a deep dive into advanced headers that hackers use to break into big systems. We focused on the Request Hijacking attack that won awards from PortSwigger and worked against giants like Google and Netflix. π
This is a high-level attack that happens because modern websites use two "guards": a Frontend Proxy (outer guard) and a Backend Server (inner guard).
An attacker sends a request that has two different rules for counting data at the same time: Content-Length (The Ruler) and Transfer-Encoding: chunked (The Conveyor Belt).
POST / HTTP/1.1
Content-Length: 15
Transfer-Encoding: chunked
0
HELP_ME_HACK
Content-Length: 15. He counts the 0, the blank lines (The Enter key is also counted as 2 chars i.e. \r\n = 2 chars), and the text HELP_ME_HACK. That are 15 characters. He says, "Check passed, move along."Transfer-Encoding: chunked. His rulebook says: "When you see a 0, the request is finished." He finds the 0 and closes the connection.0, the text HELP_ME_HACK is still sitting in the server's memory (the buffer).If the Host header lies about "Where are you going?" and the Cookie header lies about "Who you are," the User-Agent header lies about "What you are."
This header tells the server about your OS (Windows/Mac/Linux) and your browser (Chrome/Firefox/Safari) so it can serve the right layout for mobile or desktop.
Googlebot to read "Premium" articles without paying.sqlmap. If you use it, the firewall sees the name sqlmap and blocks you. To fix this, we tell the tool to lie and say its name is Chrome instead.This header (historically misspelled) tells the server where you were just before you clicked the link.
Referer: https://bank.com/login to trick the server into thinking they are an "insider."reset?token=SECRET_123) and you click a link to an external site, your browser "tells" that external site your secret token in the Referer header!The Origin is like the Referer, but it is automatically attached by your browser. You can change your own Origin, but you cannot easily force a victim's browser to lie about it.
Imagine you are logged into your bank. In another tab, you watch a "Funny Cat Video" on a hacker's site.
Origin: funny-cats.com.Lazy developers often use a wildcard: Access-Control-Allow-Origin: *. This means anyone can talk to the server. A hacker can then write a script to reach into the site and read your private messages.
This is a Response Header. It tells your browser: "Hey, the thing you want isn't here. Go there instead."
Hackers look for sites that use a "Redirect Parameter" like ?next=.
safe-bank.com/login?next=https://evil-phishing-site.com.safe-bank.com and feels safe.next part and sends back: Location: https://evil-phishing-site.com.| # | Header | Type | The Hacker's "Dirty" Goal |
|---|---|---|---|
| 1 | Host | Request | Find hidden private sites or fake password reset links. |
| 2 | Cookie | Both | Session Hijacking: Steal the ID card to log in as the user. |
| 3 | Authorization | Request | JWT Cracking: Change roles to "Admin" or crack secrets. |
| 4 | Content-Type | Both | Bypass Uploads: Upload a virus but label it as a "Photo." |
| 5 | Content-Length | Request | Smuggling: Lie about data size to hide secret commands. |
| 6 | Transfer-Encoding | Request | Smuggling: Use "chunked" pieces to confuse server guards. |
| 7 | User-Agent | Request | Masking: Pretend to be Googlebot or a mobile phone. |
| 8 | Referer | Request | Trust Bypass: Lie about where you came from to enter admin areas. |
| 9 | Origin | Request | CSRF: Exploit lazy servers that don't check the "Badge." |
| 10 | Location | Response | Open Redirect: Teleport victims to a fake phishing site. |